import streamlit as st
from auth import login_user
from auth_jwt import generate_token
from cookie_manager import set_cookie

st.title("🔐 用户登录")

username = st.text_input("用户名")
password = st.text_input("密码", type="password")

if st.button("登录"):
    if login_user(username, password):
        token = generate_token(username)
        set_cookie("token", token)
        st.success("登录成功，正在跳转...")
        st.rerun()
    else:
        st.error("用户名或密码错误")
